Ext.define('Intranet.Desktop.view.PersonalPanel', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.desktop_personalpanel',
    layout: 'column',
    title: 'Personal',
    width: 1100,
    collapsible: true,
    
    id: 'personal_panel',
    
    defaults: {
        style: 'margin: 10px 5px;',
        border: false
    },
    items: [{
            columnWidth: 0.33,
            defaults: {
                style: 'margin-bottom: 10px;'
            },
            items: []
        }, {
            columnWidth: 0.33,
            defaults: {
                style: 'margin-bottom: 10px;'
            },
            items: []
        }, {
            columnWidth: 0.33,
            defaults: {
                style: 'margin-bottom: 10px;'
            },
            items: []
        }],
    initComponent: function()
    {
        var thisComponent = this;

        this.callParent(arguments);

        Ext.Ajax.request({
            url: '/src/public/module/modulesusers/getModules',
            success: function(response) {

                var data = Ext.decode(response.responseText);

                if (data.success === 'true')
                {
                    thisComponent.items.items[0].removeAll();
                    thisComponent.items.items[1].removeAll();
                    thisComponent.items.items[2].removeAll();

                    var index = 0;

                    for (var i = 0; i < data.modules.length; i++)
                    {
                        if (data.modules[i].group_id === '3')
                        {
                            var module_name = data.modules[i].key_name;

                            var item = Ext.widget(module_name + '_MiniView');

                            thisComponent.items.items[index % 3].add(item);

                            index++;
                        }
                    }
                }
                else
                {
                    Ext.Msg.alert('Get Modules failed', data.msg);
                }

            }
        });
    }
    

});



